
<?php
include("../connection.php");
include("heder1.php");
if($_GET['action']=="delete")
{
 $id=$_GET['id'];
 mysql_query("DELETE FROM booking WHERE bookingid='".$id."'")or die(mysql_error());
 echo"deleted";
}
if($_GET['action']=="nopay")
{
 mysql_query("UPDATE booking SET payment=0 WHERE bookingid='".$id."' ")or die(mysql_error());
				 
}
if($_GET['action']=="pay")
{
 mysql_query("UPDATE booking SET payment=1 WHERE bookingid='".$id."' ")or die(mysql_error());
				  
}

if($_GET['action']=="aprovel")
{
 mysql_query("UPDATE booking SET approval=1 WHERE bookingid='".$id."' ")or die(mysql_error());
				 
}
if($_GET['action']=="notaprovel")
{
 mysql_query("UPDATE booking SET approval=0 WHERE bookingid='".$id."' ")or die(mysql_error());
				  
}




		
	$result=mysql_query("SELECT * FROM booking");
	$total = mysql_num_rows($result);
	$i=0;
	 echo'<table width="600" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>bookingid</td>
    <td>userid</td>
    <td>eventid</td>
    <td>payment</td>
    <td>approval</td>
  </tr>';


	while($i< $total)
	{
	$row=mysql_fetch_array($result);
	$bookingid=$row["bookingid"];
	$userid=$row["userid"];
	$eventid=$row["eventid"];
	$payment=$row["payment"];
	$approval=$row["approval"];
		
		
		$q=mysql_query("SELECT * FROM users WHERE Id='".$userid."'")or die(			        mysql_error());
	   $r=mysql_fetch_array($q);	
	   $fname=$r["fname"];
	   $lname=$r["lname"];
	
	$qo=mysql_query("SELECT * FROM event WHERE id='".$eventid."'")or die(			     mysql_error());
	$ro=mysql_fetch_array($qo);	
	$eventname=$ro["eventname"];
	   
	
	
	//echo $eventname."<br>";
	//echo $vanue."<br>";
	//echo $date."<br>";
	echo"
	<tr>
	<td>".$fname." ".$lname." (".$bookingid.")</td>
    <td>".$userid."</td>
    <td> ".$eventname."  (".$eventid.")</td><td>";
	if($payment==0)
	{
	echo"<a href=?action=pay&id=".$bookingid.">not paid</a>";
	}
	else
	{
	echo"<a href=?action=nopay&id=".$bookingid.">paid</a>";
	}
	
   echo"</td>";
   echo"<td>";
   if($approval==0)
	{
	echo"<a href=?action=aprovel&id=".$bookingid.">not active</a>";
	}
	else
	{
	echo"<a href=?action=notaprovel&id=".$bookingid.">active</a>";
	}
	
   echo"</td>";

    
	echo"<td><a href='?action=delete&id=".$row["bookingid"]."'><img src='delete.png' border='0'/></a>   </td>
    
	
	</tr>";
	
	$i++;
	}
	echo "</table>";
	include("../footer.php");
	
	?>	